function obj_eval = obj_function(param_unc,fp)
tic
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%;
%To constraint the structural parameters;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%;

%Technology (Cobb-Douglas, PS=1);
param_con(1) = param_unc(1)/100; %CES Elasticity (   Parents vs Peers, inner)
param_con(2) = exp(param_unc(2)/100)./(1 + exp(param_unc(2)/100) );         %CES Share Skills ;
param_con(3) = exp(param_unc(3)/100)./(1 + exp(param_unc(3)/100) );         %CES Share Peers;
param_con(4) = param_unc(4)/100; %CES Elasticity ( Skills vs Parents-Peers, outer);
param_con(5) = param_unc(5)/100 ; %Return to Scale CES;


fprintf('New CES Parameters for Technology of Authoritarian Parents (P=1) \n')
fprintf('Figure E-1: Policy and Scaling Effects on Skills (Alternative Calibration) \n')

fprintf('alpha_{1,1} =  %1.4f \n',param_con(1))

fprintf('alpha_{2,1} =  %1.4f \n',param_con(2))

fprintf('alpha_{3,1} =  %1.4f \n',param_con(3))

fprintf('alpha_{4,1} =  %1.4f \n',param_con(4))

fprintf('alpha_{5,1} =  %1.4f \n',param_con(5))

param_con(6) = param_unc(6)/100;         %Parenting Style (alpha0);

%Technology (CES, PS=0);
param_con(7) = exp(param_unc(7)/100)./(1 + exp(param_unc(7)/100) );         %CES Elasticity (   Parents vs Peers, inner)
param_con(8) = exp(param_unc(8)/100)./(1 + exp(param_unc(8)/100) );         %CES Share Skills ;
param_con(9) = exp(param_unc(9)/100)./(1 + exp(param_unc(9)/100) );         %CES Share Peers;
param_con(10) = -exp(param_unc(10)/100) ;                                     %CES Elasticity ( Skills vs Parents-Peers, outer);
param_con(11) = param_unc(11)/100 ;                                           %Return to Scale CES;

param_con(12) = param_unc(12)/100;           %TFP constant;
param_con(13) = param_unc(13)/100;           %TFP trend;

ind  = 13 ;

%Parent's Preferences;

param_con(ind+1) =      exp(param_unc(ind+1)/100);                    %Weight on Children's Skills;
param_con(ind+2) =      param_unc(ind+2)/100 ;                        %Disutility of PS;
param_con(ind+3) =      param_unc(ind+3)/100 ;                        %Heterogeneity in PS;

ind  = ind + 3 ;

%Child's Preferences;

param_con(ind+1) =  param_unc(ind+1)/100;                       %Constant (gamma0);
param_con(ind+2) =  param_unc(ind+2)/100;                       %Own Skills (gamma1);
param_con(ind+3) =  param_unc(ind+3)/100;                       %Child j 's Skills (gamma2);
param_con(ind+4) =  param_unc(ind+4)/100;                       %Homophily (gamm3);
param_con(ind+5) =  param_unc(ind+5)/100;                       %PS effect (gamma4);


param_con(ind+6) =      param_unc(ind+6)/100 ;                   %Disutility of PS (by Neighborhood Income);


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Simulate latent variables from latent parameters
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
               
sim = sim_data_function(param_con,fp) ;


simul_data = sim.sim_data ; 
sim_data_network = sim.sim_data_network;

toc
 
if fp.do_counter == 0

Value0     =    sim.Value0;
Value1     =    sim.Value1;

obj_eval.Value0= Value0;
obj_eval.Value1= Value1;

end

obj_eval.structural_params = param_con;    
obj_eval.simul_data= simul_data;
obj_eval.sim_data_network=sim_data_network;

if fp.do_counter    == 1 && fp.do_counter_type<4
obj_eval.id_moved_children = sim.id_moved_children;
end








